package com.yunhe.javaBean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Component("user")
@Scope("singleton")//单例
//@Scope("prototype")//多例
//用于标识作用域范围 默认为单例 不书写也是默认单例
public class User {
    private  int uid;
    private  String username;
    private  String password;
    private  String phone;


    @PostConstruct  //相当于标签init-method：指定类中的初始化方法名称
    public void init(){
        System.out.println("初始化方法....");
    }
    @PreDestroy //相当于标签destroy-method：指定类中销毁方法名称
    public void destroy(){
        System.out.println("销毁方法.....");
    }

}
